#ifndef REMINDERWIDGET_H
#define REMINDERWIDGET_H

#include <QWidget>
#include <QTimer>
#include "ui_ReminderWidget.h"

class ReminderWidget : public QWidget
{
        Q_OBJECT

public:
        ReminderWidget(QString text="",QWidget *parent = Q_NULLPTR): QWidget(parent)
        {
                ui.setupUi(this);
                //设置去掉窗口边框、任务栏无标志、置于顶层
                this->setWindowFlags(Qt::FramelessWindowHint
                        | Qt::Tool
                        | Qt::WindowStaysOnTopHint);
                //设置属性：关闭即销毁
                this->setAttribute(Qt::WA_DeleteOnClose);
                //text为要显示的信息
                ui.label->setText(text);
                //设置定时器，到时关闭弹框
                QTimer* timer = new QTimer(this);
                timer->start(1500);//时间1.5秒
                timer->setSingleShot(true);//仅触发一次
                connect(timer, SIGNAL(timeout()), this, SLOT(onTimeupDestroy()));
        }

        ~ReminderWidget(){}
private slots:
        void onTimeupDestroy(){
                this->close();
        }
private:
        Ui::ReminderWidget ui;
};
